package ar.com.pragmatia.lanacion.data;

import android.database.Cursor;
import ar.com.pragmatia.lanacion.app.App;

public abstract class Domain extends AppData {

	
	private String name;
	
	
	public Cursor findAll() {
		return findAll("");
	}
	
	public Cursor findAll(String conditions) {

		conditions = " " + conditions + " ";
		String sql = "SELECT id AS _id, name FROM " + getTableName() + conditions + "ORDER BY name";
		return App.getDataHelper().getDb().rawQuery(sql, null);
		
	}
	
	
	public String findIdByName(String name) {

		Cursor c = findAll("where name like '" + name + "'");
		if (c.getCount() == 1) {
			c.moveToFirst();
			return c.getString(0);
		} else {
			return "";
		}
		
	}
	
	
	
/******************************************************************************
 * SETTERS & GETTERS
 *****************************************************************************/
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	
}
